#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
#include<stdlib.h>



char* mergeAlternately(char* word1, char* word2)
{
    char* ret = (char*)malloc(sizeof(char) * (strlen(word1) + strlen(word2) + 1));
    int n = 0;
    int i = 0, j = 0;
    while (*word1 && *word2)
    {
        ret[n++] = *word1;
        word1++;
        ret[n++] = *word2;
        word2++;
    }
    while (*word1)
    {
        ret[n++] = *word1;
        word1++;
    }
    while (*word2)
    {
        ret[n++] = *word2;
        word2++;
    }

    ret[n] = '\0';
    return ret;
}

int main()
{
    char str1[] = "sagg";
    char str2[] = "gernaeg";
    char* str = mergeAlternately(str1, str2);
    printf("%s ", str);
    free(str);
    return 0;
}